import {Component, OnInit} from '@angular/core';
import {FormBuilder, FormGroup} from '@angular/forms';
import {SharedModule} from '../shared.module';
import {MODAL_WIDTH} from '../../const'
import {FacilityMaintenanceRecord} from '../../types/resp/FacilityMaintenanceRecord';

@Component({
  selector: 'facility-maintenance-record-view',
  imports: [
    SharedModule
  ],
  templateUrl: './facility-maintenance-record-view.component.html',
  standalone: true
})
export class FacilityMaintenanceRecordViewComponent implements OnInit {
  facilityMaintenanceRecordForm!: FormGroup;
  isVisible: boolean = false
  title: string = '公共设施保养记录详情'
  modalWidth: string = MODAL_WIDTH

  constructor(
    private fb: FormBuilder
  ) {}

  ngOnInit(): void {
    this.facilityMaintenanceRecordForm = this.fb.group({
      facilityName: [''],
      maintenanceStartDate: [''],
      maintenanceEndDate: [''],
      staffName: [''],
      remark: [''],
      createTime: [''],
    })
  }

  onBack() {
    this.isVisible = false
  }

  display(facilityMaintenanceRecord: FacilityMaintenanceRecord) {
    this.isVisible = true
    this.facilityMaintenanceRecordForm.patchValue(facilityMaintenanceRecord);
    this.facilityMaintenanceRecordForm.disable();
  }
}
